<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <div @click="divClick">aaaaa
            <!-- @click.stop:阻止冒泡 -->
            <button @click.stop='btnClick'>按钮</button>
        </div>

        <br />
        <form action="baidu">
            <input type="text" name="" id="">
            <!-- @click.prevent:阻止默认事件 -->
            <input @click.prevent='submitClick' type="submit" value="提交">
        </form>

        <br />
        <!-- @keyup.enter按回车才触发 -->
        <input type="text" @keyup.enter='keyup'>
        <!-- @click.once只执行一次回调，后续不会再次触发 -->
        <button @click.once="doThis">按钮</button>
    </div>
    <script src='../js/vue.js'></script>
    <script>
        const app = new Vue({
            el: '#app',
            data: {

            },
            methods: {
                btnClick() {
                    console.log("btnClick");
                },
                divClick() {
                    console.log("divClick");
                },
                submitClick() {
                    console.log('提交');
                },
                keyup() {
                    console.log('keyup');
                },
                doThis() {
                    console.log('doThis');
                }
            }
        })
    </script>
</body>

</html>